function convert2ChartData(bridgeList){
  if(bridgeList == undefined || bridgeList == null){
    return null;
  }

  let attrMap = new Map();

  for (let i = 0; i < bridgeList.length; i++){
    var bridge = bridgeList[i];
    let avgAcross = bridge.avgAcross;
    let structureTypeName = bridge.structureTypeName;
    //每平方米混凝土（m3/m2）
    if (bridge.avgBeton>0){
      putValue(attrMap, 'avgBeton', bridge.avgBeton, avgAcross, bridge)
    }
    //每平方米钢绞线（kg/m2）
    if (bridge.avgSteelStrand){
      putValue(attrMap, 'avgSteelStrand', bridge.avgSteelStrand, avgAcross, bridge)
    }
    //每平方米普通钢筋（kg/m2）
    if (bridge.avgSteelBar) {
      putValue(attrMap, 'avgSteelBar', bridge.avgSteelBar, avgAcross, bridge)
    }
    //每平方米钢材（kg/m2）
    if (bridge.avgRolledSteel) {
      putValue(attrMap, 'avgRolledSteel', bridge.avgRolledSteel, avgAcross, bridge)
    }
    //每平方米斜拉索（kg/m2）
    if (bridge.avgStayCable) {
      putValue(attrMap, 'avgStayCable', bridge.avgStayCable, avgAcross, bridge)
    }
    //每平方米主缆及吊杆（kg/m2）
    if (bridge.avgCableBoom) {
      putValue(attrMap, 'avgCableBoom', bridge.avgCableBoom, avgAcross, bridge)
    }

    //----每平立方米上部结构材料用量/平均跨径）
    //混凝土（m3/m3）
    if (bridge.effiBeton) {
      putValue(attrMap, 'effiBeton', bridge.effiBeton, avgAcross, bridge)
    }
    //钢绞线（kg/m3）
    if (bridge.effiSteelStrand) {
      putValue(attrMap, 'effiSteelStrand', bridge.effiSteelStrand, avgAcross, bridge)
    }
    //普通钢筋（kg/m3）
    if (bridge.effiSteelBar) {
      putValue(attrMap, 'effiSteelBar', bridge.effiSteelBar, avgAcross, bridge)
    }
    //钢材（kg/m3）
    if (bridge.effiRolledSteel) {
      putValue(attrMap, 'effiRolledSteel', bridge.effiRolledSteel, avgAcross, bridge)
    }
    //斜拉索（kg/m3）
    if (bridge.effiStayCable) {
      putValue(attrMap, 'effiStayCable', bridge.effiStayCable, avgAcross, bridge)
    }
    //主缆及吊杆（kg/m3)
    if (bridge.effiCableBoom) {
      putValue(attrMap, 'effiCableBoom', bridge.effiCableBoom, avgAcross, bridge)
    }
  }
  return attrMap;
}

function putValue(map, key, value, avgAcross,bridge){
  let keyTemp = key + '-' + bridge.structureTypeName;
  var data = map.get(keyTemp);
  if(data == undefined || data == null){
    data = new Array();
    map.set(keyTemp,data);
  }
  let arr1 = [avgAcross, value];
  data.push(arr1);
}

module.exports = {
  convert2ChartData: convert2ChartData
}